﻿<!--#include file="../Inc/easp/easp.asp"-->
<!--#include file="../Inc/conn1.asp"-->
<!--#include file="../inc/checklogin.asp"-->
<% CheckLogin("index.asp") %>
<%
	If Session("Authority")<>"0" Then
		Response.Write "<script type=""text/javascript"">top.location.href='../main.asp';</script>"
	end if
	
	Dim g_id,auth,username,password,password1
	g_id = Easp.Get("gid")'获取组ID.这个只会在选择组下拉列表时用的，本页面刷新
	auth = Easp.Get("auth")'获取权限值.这个只会在选择组下拉列表时用的，本页面刷新
	username = Easp.Get("username")
	password = Easp.Get("password")
	password1 = Easp.Get("password1")
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add User</title>
<link rel="stylesheet" type="text/css" href="../css/theme.css" />
<link rel="stylesheet" type="text/css" href="../css/style.css" />
<script type="text/javascript">
	var StyleFile = "theme" + document.cookie.charAt(6) + ".css";
	document.writeln('<link rel="stylesheet" type="text/css" href="../css/' + StyleFile + '">');
</script>
<script language="javascript" type="text/javascript">
function checkform(obj)
{	
	if (obj.username.value == "")
	{
		alert("Please Input UserName!");
		obj.username.focus();
		return false;
	}
	if (obj.password.value =="")
	{
		alert("Please Input Password!");
		obj.password.focus();
		return false;
	}
	if (obj.password1.value == "")
	{
		alert("Please Input Password again!")
		obj.password1.focus();
		return false;
	}
  if (obj.password1.value != obj.password.value)
  {
  	alert("Password is not consistent!");
  	obj.password.focus();
  	return false;
  }
		
	return true;
}

	function getRadioValue(radioName)
	{	  
	  var obj = document.getElementsByName(radioName);	  
	  if (obj != null)
	  {
	    var i;
		for (i = 0; i < obj.length; ++i)
		{		  
		  if(obj[i].checked)
		  {
		    return obj[i].value;
		  }
		}
	  }
	  return null;
	}

function change()
{
	    var obj = document.getElementById("GroupList");
	    var selectedindex = obj.selectedIndex;
	    var gid = obj.options[selectedindex].value;
		  var atu = getRadioValue("radio");
		  var user_name = document.getElementById("username").value;
		  var pass_word = document.getElementById("password").value;
		  var pass_word1 = document.getElementById("password1").value;
		  
		  top.location.href="add.asp?gid=" + gid + "&auth=" + atu + "&username=" + user_name + "&password=" + pass_word + "&password1=" + pass_word1;
}
</script>
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="../css/ie-sucks.css" />
<![endif]-->
</head>
<body>
<div id="container">
	<div id="header">
    <div id="divAccount" style="float:right;">
        <a href="../user/account.asp" style="color:white">Account</a>&nbsp;&nbsp;&nbsp;&nbsp;
        <a href="../inc/logout.asp" style="color:white">Logout</a>
      </div>
		<h2>Add User</h2>
		<div id="topmenu">
			<ul>
				<li><a href="../main.asp">Home</a></li>
				<li><a href="../Country/index.asp">Country</a></li>
				<li><a href="../holiday/index.asp">Holiday</a></li>
				<li><a href="../Times/index.asp">Times</a></li>
				<% 
				    If Session("Authority")="0" Then 
				        Response.Write("<li class=""current""><a href='#'>User</a></li>")
				    End if
				%>
				<li><% If Session("Passed")=true Then %><a href="../inc/logout.asp">Logout</a><% End If %></li>
			</ul>
		</div>
	</div>
	<div id="top-panel">
		<div id="panel">
			<ul>
				<li><a href="<%=request.serverVariables("Http_REFERER")%>" class="goback">GoBack</a></li>
			</ul>
		</div>
	</div>
	<div id="wrapper">
		<div id="content">
			<div id="rightnow">
				<h3 class="reallynow"> 
					<span>Add User</span> 					
					<br />
				</h3>				
					<form id="form" action="Createuser.asp" method="post" onSubmit="return checkform(this);">
				    <div id="box">
					    <table style="width:500px;text-align: center;margin:auto;">
						    <tbody>
						    	<tr>
						    		<td style="border:0">User Name:</td>
						    		<td style="border:0"><input name="username" id="username" type="text" tabindex="1" class="ipt" value="<%=username %>" /></td>
						    		<td style="border:0">*</td>
						      </tr>						        
						      <tr>
						      	<td style="border:0">Choose a password:</td>
						        <td style="border:0"><input id="password" name="password" type="password" tabindex="1" class="ipt" value="<%=password %>" /></td>
						        <td style="border:0">*</td>
						      </tr>
						      <tr>
						      	<td style="border:0">Re-Enter Password:</td>
						        <td style="border:0"><input id="password1" name="password1" type="password" tabindex="1" class="ipt" value="<%=password1 %>" /></td>
						        <td style="border:0">*</td>
						      </tr>
						      <tr>
						      	<td style="border:0">Authority:</td>
						        <td style="border:0">
						        	<%
						        	  If auth = "1" then
						        	    Easp.wc "<input type='radio' id='radio' name='radio' value='2' />&nbsp;Read & Write"
           				        Easp.wc "<input type='radio' id='radio' name='radio' value='1' checked/>&nbsp;Read Only"
									      Else
									        Easp.wc "<input type='radio' id='radio' name='radio' value='2' checked />&nbsp;Read & Write"
           				        Easp.wc "<input type='radio' id='radio' name='radio' value='1'/>&nbsp;Read Only"
									      End If 
						        	%>						        				        	
						        	</td>
						        <td style="border:0">*</td>
						      </tr>
						      <tr>
						      	<td style="border:0">Group:</td>
						      	<td style="border:0">
						      		<select name="GroupList" style="width:200px" onchange="change();">
						      			<%
						      			  Dim curgid
									        Dim rsgroup
									        Set rsgroup = Easp.db.GetRecordBySql("select * from [Group]")'查询所有组
									        If Not Easp.IsN(rsgroup) Then
									          if g_id<>"" then curgid = g_id else curgid = rsgroup("ID")'取当前显示的组ID。用来显示该组的国家用
									          While Not rsgroup.eof
										          Easp.w "<option value='" & rsgroup("ID") & "'"                                           
                              If g_id = Trim(rsgroup("ID")) Then
										            Easp.w "selected"
                              End If 
                              Easp.wc ">" & rsgroup("GroupName") & "</option>"
                              rsgroup.movenext()
										        Wend 
									        End If
									        Easp.db.C(rsgroup)
						      			%>
						      	  </select>
						      	</td>
						      </tr>
						      <tr>
						      	<td style="border:0">Dispatch Country:</td>
						      	<td style="border:0">
						      		<select name="CountryList" size="10" multiple="multiple" style="width:200px">
						      			<%
						      			  '添加国家列表
						      			  dim rs
						      			  set rs = Easp.db.GetRecordBySql("select * from Country where g_id=" & curgid)'查找所有还没分配的国家
						      			  If not Easp.IsN(rs) Then
						      			  	while not rs.eof
						      			  	  Easp.wc "<option value='" & rs("y_id") & "'>" & rs("CountryName") & "</option>"
						      			  	  rs.MoveNext()
						      			  	wend
						      			  End If
						      			  Easp.db.C(rs)
						      			%>
						      		</select>
						      	</td>
						      	<td style="border:0"></td>
						      </tr>
						    </tbody>
						  </table>
						  <div id="pager">
						  	<input class='btn' type='submit' name='submit' value='Add' />
						    <input class='btn' type='reset' name='reset' value='Reset' />
						  </div>
						</div>
					</form>
				
			</div>
		</div>
	</div>
	<!--#include file="../inc/footer.asp" -->
</div>
</body>
</html>

